package com.onlyMe.world.objects
{
	import com.onlyMe.config.objects.object.ObjectNode;
	import com.onlyMe.globals.config;
	import com.onlyMe.world.components.ComponentCreator;

	public final class IsleObjectCreator
	{
		private var componentCreator:ComponentCreator = new ComponentCreator();
		
		public function IsleObjectCreator()
		{
		}
		
		public function create(id:int):IsleObject
		{
			var node:ObjectNode = config.objects.getById(id);
			var object:IsleObject = new IsleObject(node.type, id);
			
			for each (var component:XML in node.components)
				object.register(componentCreator.create(component));
				
			object.initialize();
			return object;
		}
	}
}